<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center searchRusult_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub searchRusult_fd0_0'>
					<view class='flex flex-wrap align-center searchRusult_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  searchRusult_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='searchRusult_fd0_0_c1_c0'>搜索结果</text>
					</view>
					<view class='flex flex-wrap align-center justify-end searchRusult_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			
			<view class="loading_css" v-if="isShow">
				<u-loading size="36" color="#3090FF"></u-loading>
				<view>加载中</view>
			</view>
			
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout searchRusult_flex_1" v-else>
				<template v-for="(item, index) in list">
					<course :item="item"></course>
				</template>
				<view class="loadmore" v-if="last_page > 1">
					<u-loadmore font-size="24" :status="status" :icon-type="iconType" :load-text="loadText" />
				</view>
			</view>
			<view class="noData" v-if="list.length == 0 && !isShow">
				<image :src='STATIC_URL+"no.png"'></image>
			</view>
			<!---flex布局flex布局结束-->

		</view>
	</view>
</template>
<script>
	import course from "@/components/course/index.vue"
	export default {
		components: {
			course
		},


		data() {
			return {
				"keyword": '',
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": true,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {keyword} = options;
			if (keyword !== undefined) this.keyword = keyword;
			this.getList();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.getList();
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.getList();
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			getList() {
				this.$api.post(global.apiUrls.post65743a8776b1d, {
					is_recommend: 0,
					page: this.page,
					keyword: this.keyword
				}).then(res => {
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #FFFFFF;
		background-size: 100% auto;
	}

	.searchRusult_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.searchRusult_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
		line-height: 50rpx;
	}

	.searchRusult_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.searchRusult_fd0_0_c0 {
		width: 120rpx;
	}

	.searchRusult_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.searchRusult_flex_1 {
		padding: 5rpx 30rpx 5rpx 30rpx;
	}

	.searchRusult_fd1_1_c1_c2_c0 {
		height: 30rpx;
	}

	.searchRusult_fd1_0_c1_c2_c1_c0 {
		font-size: 28rpx;
		color: var(--benbenFontColor3);
	}

	.searchRusult_fd1_0_c1_c2_c1 {
		background: var(--benbenbgColor0);
		background-size: 100% auto;
		width: 176rpx;
		height: 60rpx;
		border-radius: 12rpx;
	}

	.searchRusult_price1_fd1_0_c1_c2_c0_c1 {
		font-size: 34rpx;
		color: rgba(255, 70, 32, 1);
	}

	.searchRusult_fd1_0_c1_c2_c0_c1 {
		color: #ff5536;
		font-weight: 600;
	}

	.searchRusult_fd1_0_c1_c2_c0_c0 {
		font-size: 22rpx;
		font-weight: 700;
		color: rgba(255, 70, 32, 1);
	}

	.searchRusult_fd1_0_c1_c1_c0 {
		font-size: 24rpx;
		color: rgba(167, 166, 167, 1);
		line-height: 34rpx;
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		margin: 8rpx 0rpx 20rpx 0rpx;
	}

	.searchRusult_fd1_0_c1_c0_c0 {
		font-size: 32rpx;
		font-weight: 700;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.searchRusult_fd1_0_c1 {
		padding: 0rpx 0rpx 0rpx 24rpx;
	}

	.searchRusult_fd1_0_c0_c0 {
		width: 260rpx;
		height: 200rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchRusult_fd1_0 {
		margin: 20rpx 0rpx 20rpx 0rpx;
	}
</style>